package com.ce.pms.charge.service.impl;

import java.util.List;

import com.ce.pms.base.service.impl.PmsBaseServiceImpl;
import com.ce.pms.charge.dao.IPeriodLogDao;
import com.ce.pms.charge.model.PeriodDomain;
import com.ce.pms.charge.service.IPeriodLogService;
import com.ce.pms.charge.vo.PeriodVO;
import com.ce.pms.common.model.SysrefcodeDO;
import com.ce.util.BlankUtil;

public class PeriodLogServiceImpl extends PmsBaseServiceImpl implements IPeriodLogService {

	private IPeriodLogDao periodLogDao ;

	/**
	 * 功能描述:检查在日志表中每一个收费周期是否都有相应的流程日志<br>
	 * @param list 收费周期集合
	 * @param flowDefId  流程ID
	 * @return true :全部存在相应的记录  false ：至少有一条不存在
	 * Create author:黄彦军 <br>
	 * Create on:2008-8-29  <br>
	 * Edit author:  <br>
	 * Edit on:    <br>
	 * Why:     <br>
	 */
	public boolean checkReceivableLog(List<PeriodVO> list) {
		if ( BlankUtil.isBlank(list)){
			return true;
		}
		for (PeriodVO periodVO : list) {
			Long periodID = periodVO.getKeyword();
			List logs = periodLogDao.findLogByPeriodAndFlowDef(periodID,SysrefcodeDO.FEE_FLOW_DEF_NAME_RECEIVABLE);
			if (BlankUtil.isBlank(logs) || logs.size() < 1){
				return false;
			}
		}
		return true;
	}

	/**
	 * 功能描述:检查在日志表中每一个收费周期是否都有相应的流程日志<br>
	 * @param list 收费周期集合
	 * @param flowDefId  流程ID
	 * @return true :全部存在相应的记录  false ：至少有一条不存在
	 * Create author:黄彦军 <br>
	 * Create on:2008-8-29  <br>
	 * Edit author:  <br>
	 * Edit on:    <br>
	 * Why:     <br>
	 */
	public boolean checkNoticeLog(List<PeriodVO> list) {
		if (BlankUtil.isBlank(list)){
			return true;
		}
		for (PeriodVO periodVO : list) {
			Long periodID = periodVO.getKeyword();
			List logs = periodLogDao.findLogByPeriodAndFlowDef(periodID,SysrefcodeDO.FEE_FLOW_DEF_NAME_NOTICE);
			if (BlankUtil.isBlank(logs) || logs.size() < 1){
				return false;
			}
		}
		return true;
	}


	public IPeriodLogDao getPeriodLogDao() {
		return periodLogDao;
	}

	public void setPeriodLogDao(IPeriodLogDao periodLogDao) {
		this.periodLogDao = periodLogDao;
	}

}
